package com.bs.bsacexj.service.impl;

import com.alibaba.fastjson2.JSON;
import com.bs.bsacexj.domain.AccessControlEventInfoVO;
import com.bs.bsacexj.domain.PersonInfoVO;
import com.bs.bsacexj.service.IUploadACEventInfoService;
import okhttp3.*;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.List;

@Service
public class UploadACEventInfoService implements IUploadACEventInfoService {


    @Override
    public Boolean uploadACEventInfo(List<AccessControlEventInfoVO> eventList) {
        OkHttpClient client = new OkHttpClient();
        String url = "https://aqdlbz-sit.bosafe.com//prod-api/business/accessControlApi/doorEvents";
        MediaType mediaType = MediaType.get("application/json; charset=utf-8");
        RequestBody requestBody = RequestBody.create(mediaType, JSON.toJSONString(eventList));
        Request request = new Request.Builder()
                .url(url)
                .post(requestBody)
                .build();
        try (
                Response response = client.newCall(request).execute()) {
                ResponseBody body = response.body();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return true;
    }



}
